const { List, ListNode, List2Array } = require('./common')
var deleteNode = function (head, val) {
  let dummyHead = new ListNode(undefined, head)
  for (let p = dummyHead; p.next; p = p.next) {
    if (p.next.val == val) {
      p.next = p.next.next
      break;
    }
  }
  return dummyHead.next
}

console.log(List2Array(deleteNode(List([1,2,3,4]), 4)));